<?php
require_once 'models/discounts.inc';
require_once 'models/orm.inc';
require_once 'models/TCatalogProductModel.inc';
require_once 'models/TMSOrderModel.inc';

class TMSClientDiscountItem extends TCandyItem {
	public function GetAmount(TMSProductItem $article){
		return $this->Discount->GetAmount($article,$this->Client,$this->Points);
	}
	
	public function PointsIncrement(TMSOrderItem $order){
		return $this->Discount->PointsIncrement($order, $this->Points);
	}
	
	public function PointsDecrement(TMSOrderItem $order, $discount_amount){
		return $this->Discount->PointsDecrement($order,$this->Points,$discount_amount);
	}
}


class TMSClientDiscountModel extends TCandyModel {
	protected function afterConstruct(){
		$this->_conf_classname_ = 'TMSClientDiscount';
		$this->_array_id_properties_ = array('Client','Discount');
	}
		
/**
 * @param object $object
 * @return TCandyItem
 */
	public function WrapObject($object, array &$caller_stack = array()){
		if ($object instanceof $this->_conf_classname_)
			return new TMSClientDiscountItem($object,$this);
		return parent::WrapObject($object,$caller_stack);
	}
	
}